package com.zzq.my.jetpacks.jectpackapp.ui.act

import `in`.srain.cube.actionqueque.ActionQueue
import android.view.View
import by.kirich1409.viewbindingdelegate.viewBinding
import com.aisier.architecture.base.BaseActivity
import com.zzq.my.jetpacks.jectpackapp.R
import com.zzq.my.jetpacks.jectpackapp.action.PopDialogAction
import com.zzq.my.jetpacks.jectpackapp.databinding.ActivityActionQueueBinding


/**
 * 描述：ActionQueue 允许你一个一个的执行任务。
 * 作者：zhuangzeqin
 * 时间: 2022/1/18-17:04
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class ActionQueueActivity : BaseActivity(R.layout.activity_action_queue),View.OnClickListener{
    private val binding by viewBinding(ActivityActionQueueBinding::bind)
    val mActionQueue = ActionQueue()
    var mMessageList = arrayOf(
        "message 1",
        "message 2",
        "message 3"
    )
    /**
     * 初始化数据
     */
    override fun initData() {


    }

    private fun showDialogWithQueue() {
        for (i in mMessageList.indices) {
            val message: String = mMessageList[i]
            val action = PopDialogAction(this@ActionQueueActivity, message)
            {
                mActionQueue.notifyActionDoneThenTryToPopNext()
            }
            mActionQueue.add(action)
        }
    }

    /**
     * 初始化操作
     */
    override fun initView() {

    }

    /**
     * 初始化点击事件操作
     */
    override fun eventOnClick() {

        binding.btnActionQueue.setOnClickListener {
            showDialogWithQueue()
        }

    }

    override fun onClick(v: View) {

    }

}